﻿using System.Dynamic;

namespace CodingExercises._21_30;

// 使用字符串格式化的唯一任务标识
public class TaskItem
{
    public Guid Id { get; set; }

    public string Description { get; set; }

    public TaskItem(Guid id, string description)
    {
        Id = id;
        Description = description;
    }

    public static TaskItem Create(string description)
    {
        return new TaskItem(
            Guid.NewGuid(), description);
    }

    public override string ToString()
    {
        var guidPrefix = Id.ToString().Substring(0, 8);
        return $"Task [{guidPrefix}]:{Description}";
    }
}